<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>申购单列表---申请人</title>
    <%= stylesheet_link_tag "../javascripts/ext/resources/css/ext-all.css" %>
    <%= stylesheet_link_tag "/stylesheets/images.css" %>

    <%= javascript_include_tag "ext/adapter/ext/ext-base.js" %>
    <%= javascript_include_tag "ext/ext-all.js" %>
    <%= javascript_include_tag "ext/src/locale/ext-lang-zh_CN.js" %>
    <%= javascript_include_tag "/javascripts/application.js" %>
    <script type="text/javascript">
      Ext.onReady(function(){
        //searchForm
        var purchaseNo = new Ext.form.TextField({
          fieldLabel: '申购单号',
          allowBlank: false,
          blankText: "申购单位不能为空",
          name: 'order_number',
          anchor: '96%'
        });

        var productName = new Ext.form.TextField({
          fieldLabel: '产品名称',
          allowBlank: false,
          blankText: "产品名称",
          name: 'product_name',
          anchor: '96%'
        });

        var fundingAccount = new Ext.form.TextField({
          fieldLabel: '经费账号',
          name: 'funding_account',
          anchor: '90%'
        });

        var unitPriceFrom = new Ext.form.NumberField({
          fieldLabel: '单价(从)',
          name: 'unit_price_from',
          allowBlank: false,
          allowDecimals: false,
          allowNegative: false,
          anchor: '95%'
        });

        var unitPriceTo = new Ext.form.NumberField({
          fieldLabel: '到',
          name: 'unit_price_to',
          allowBlank: false,
          allowDecimals: false,
          allowNegative: false,
          anchor: '95%'
        });

        var amountFrom = new Ext.form.NumberField({
          fieldLabel: '总额(从)',
          name: 'amount_from',
          allowBlank: false,
          allowDecimals: false,
          allowNegative: false,
          anchor: '95%'
        });

        var amountTo = new Ext.form.NumberField({
          fieldLabel: '到',
          name: 'amount_to',
          allowBlank: false,
          allowDecimals: false,
          allowNegative: false,
          anchor: '95%'
        });

        //搜索按钮
        var searchButton = new Ext.Button({
          text: '搜索',
          iconCls: 'finding',
          handler: function(){
            searchButton.setDisabled(true);
            if (searchPurchaseForm.form.isValid()) {
              searchPurchaseForm.form.submit({
                success: function(result, resp){
                  if (resp.result.info.indexOf("成功") >= 0) {

                  } else {
                    Ext.MessageBox.alert('消息', resp.result.info);
                    searchButton.enable();
                  }
                },
                failure: function(result, request){
                  searchButton.enable();
                  Ext.MessageBox.alert('消息', '服务器的通信失败!');
                }
              });
            }
            else {
              searchButton.enable();
              //Ext.MessageBox.alert('输入验证有错', '请输入必输选项');
            }
          }
        })
        
        var searchPurchaseForm = new Ext.FormPanel({
          labelWidth: 55, // label settings here cascade unless overridden
          url:'/purchase/create',
          frame:true,
          labelAlign: 'right',
          buttonAlign: 'right',
          //title: '添加申购单',
          bodyStyle:'padding:5px 5px 0',
          width: 800,
          height:300,
          items: [
            {
              xtype: 'fieldset',
              title: '组合产品必选项',
              defaults: {width: 610},
              border: true,
              items: [{
                  layout: 'column',
                  items: [{
                      columnWidth: .3,
                      layout: 'form',
                      border: false,
                      items: [purchaseNo]
                    }, {
                      columnWidth: .3,
                      layout: 'form',
                      items: [productName]
                    }, {
                      columnWidth: .3,
                      layout: 'form',
                      items: [fundingAccount]
                    }]
                }]
            }]
        });

        searchPurchaseForm.render("search_form");

        var top = new Ext.FormPanel({
          labelAlign: 'right',
          frame:true,
          title: 'Multi Column, Nested Layouts and Anchoring',
          bodyStyle:'padding:5px 5px 0',
          width: 600,
          items: [
            {
              xtype:'fieldset',
              title: 'Phone Number',
              defaults: {width: 610},
              items :[
                {
                  layout:'column',
                  items:[{
                      columnWidth: .3,
                      layout: 'form',
                      border: false,
                      items: [unitPriceFrom]
                    }, {
                      columnWidth: .3,
                      layout: 'form',
                      items: [unitPriceTo]
                    }, {
                      columnWidth: .3,
                      layout: 'form',
                      items: [amountFrom]
                    }]
                }]
            }],

          buttons: [{
              text: 'Save'
            },{
              text: 'Cancel'
            }]
        });

        top.render("purchase_list");

      })
    </script>
  </head>
  <body>
    <div id="search_form"></div>
    <div id="purchase_list"></div>
    <div id="workbench_panel"></div>
  </body>
</html>
